<template>
  <div class='wrapper' ref="goTop" @scroll="scroll">
    <img class="go-top-img" @click="GoTop" v-show="Show"
         src="https://assets-louxun-formal.oss-cn-shenzhen.aliyuncs.com/resourecs/mweb/client/img/df259b1.png" alt="">
  </div>
</template>

<script>
  export default {
    name: 'goTop',
    data () {
      return {
        Show: true,
        pos: 0
      }
    },
    // 方法
    methods: {
      GoTop () {
        document.documentElement.scrollTop = 0
      },
      scroll (event) {
        console.log('1111')
        console.log(event)
        this.pos = event.target.scrollTop
        console.log(this.pos)
      }
    },
    // 生命钩子
    mounted () {

    }
  }
</script>

<style scoped lang="stylus">
  @import "~styles/varibles.styl"
  .go-top-img
    width .8rem
    height .8rem
    position fixed
    bottom 2rem
    right .3rem
    text-align right


</style>
